// eslint-disable-next-line no-undef
const fs = require('fs')

function appendCode(content) {
  let code = JSON.parse(content)
  code.forEach((item) => {
    if (item.code.length < 6) {
      item.code += '0000'
    }
    if (item.children) {
      item.children.forEach((item2) => {
        if (item2.code.length < 6) {
          item2.code += '00'
        }
      })
    }
  })
  fs.writeFileSync('./area2.json', JSON.stringify(code), 'utf-8')
}
let fileContent = fs.readFileSync('./area.json', 'utf-8')
console.log(fileContent)
appendCode(fileContent)
